Skip to content

Conversation

@buffalojoec
Copy link
Contributor

This PR rewrites all program tests with Mollusk instead of solana-program-test.

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good! Just one little question on whether one of the stores is needed

create_config_account(
&mut context,
&config_keypair,
vec![(pubkey, false), (pubkey, false), (pubkey, false)], // Dummy keys for account sizing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank goodness for removing this, it confused the crap out of me during the first review 😅

Comment on lines 435 to 446
let instruction = config_instruction::store(&config, true, keys.clone(), &my_config);
let result = mollusk.process_and_validate_instruction(
&instruction,
&[
(config, config_account),
(signer0, AccountSharedData::default()),
],
&[Check::success(), Check::compute_units(3_324)],
);

// Use this for next invoke.
let updated_config_account = result.get_account(&config).unwrap().to_owned();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this part actually needed since you're storing the proper account data from the start?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically you're right that would also work, but to be extra sure I wanted to pipe the newly created config account state into the "update" instruction. The create_config_account helper uses the default value (uninitialized data) to space the account, and the first invoke sets it to MyConfig::new(42). This way we get to assert a valid transition from MyConfig::new(42) to MyConfig::new(84).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok great, the new change looks good!

@buffalojoec buffalojoec merged commit 178873c into main Oct 14, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants